using System;
using Slobby.Common;

/* Authentication
 * Messages to client denoted by -> and messages to server by <-
 * 
 * connect
 * <- Version  (client version)
 * -> Version  (if client's version is invalid: the version the server expected, then disconnect)
 * <- Authenticaton (auth details)
 * -> PassedAuthentication (if passed, otherwise disconnect)
 * 
 * yay connected \o/
 * 
 * all out of order/other messages are to be ignored until connection is complete
 */

namespace Slobby.SharedNetworkTypes {
    [Serializable]
    public struct TryAuthenticationMessage {
        public TryAuthenticationMessage(string userName, string credentials) {
            UserName = userName;
            Credentials = credentials;
        }
        public string UserName;
        public string Credentials;
        public override string ToString() {
            return "TryAuthenticationMessage: " + UserName;
        }
    }

    [Serializable]
    public struct PassedAuthenticationMessage { }

    [Serializable]
    public struct VersionMessage {
        public VersionMessage(Version version) {
            Major = version.Major;
            Minor = version.Minor;
            Build = version.Build;
        }
        public Version ToVersion() {
            return new Version(Major, Minor, Build);
        }
        public int Major, Minor, Build;

        public override string ToString() {
            return "VersionMessage: " + ToVersion().ToString();
        }
    }
}